/**
 * Copyright (c) 2011-11-10 WKM and/or its affiliates. 
 * Use is subject to license terms.
 * All rights reserved.
 */
package org.wkm.definition;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Date;

import javax.imageio.ImageIO;

/**
 * @author WKM Modification history 1.WKM - 2011-11-10 -Create File
 */
public class ScreenCapture {

	/**
	 * 计算机截屏
	 * @throws AWTException
	 * @throws IOException
	 */
	public void screen() throws AWTException,IOException{
		// 机器人
		Robot robot = new Robot();
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		BufferedImage buffer = robot.createScreenCapture(new Rectangle(0, 0, d
				.getSize().width, d.getSize().height));
		ImageIO.write(buffer, "PNG", new File("D:/other/img/"
				+ new Date().getTime() + ".jpg"));
	}
}
